# class dog:
#     name = "小白"
#
#     @classmethod
#     def set_name(cls, name):
#         cls.name = name  # 通过类方法的形参,改修类属性的name值
#
#     def __init__(self):
#         self.age = 20  # 在类方法里面无法访问age
#
#     def demo(self):  # 在类方法中无法调用demo
#         print("这是一个dome")
#
#
# print(dog.name)  # 显示类属性
# dog.name = "狼狗"
# print(dog.name)
#
# dog.set_name("二哈")
# print(dog.name)


class A(object):
    # name为类属性
    name = "tom"

    @classmethod
    def show_name(cls):   # show_name为类方法
        print(cls.name)

    def set_name(self, name):   # set_name为普通方法
        A.name = name


A.show_name()
a = A()
a.set_name("mary")
A.show_name()
